<script setup lang="ts">
import { ref, nextTick } from "vue";
import { formRules } from "../utils/rule";
import { FormProps } from "../utils/types";

const props = withDefaults(defineProps<FormProps>(), {
  formInline: () => ({
    id: "",
    categoryName: "",
    sort: undefined
  })
});

const ruleFormRef = ref();
const newFormInline = ref(props.formInline);

function getRef() {
  return ruleFormRef.value;
}

defineExpose({ getRef });
</script>

<template>
  <el-form
    ref="ruleFormRef"
    :model="newFormInline"
    :rules="formRules"
    label-width="100px"
  >
    <el-row>
      <el-col :span="16" class="m-auto">
        <el-form-item label="标签分类" prop="categoryName">
          <el-input
            v-model="newFormInline.categoryName"
            clearable
            placeholder="请输入标签分类"
          />
        </el-form-item>
      </el-col>
    </el-row>

    <el-row>
      <el-col :span="16" class="m-auto">
        <el-form-item label="排序" prop="sort">
          <el-input
            v-model="newFormInline.sort"
            clearable
            placeholder="请输入排序"
          />
        </el-form-item>
      </el-col>
    </el-row>
  </el-form>
</template>
